package com.ruoyi.web.controller.car;

import com.ruoyi.car.service.ICarService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.car.CarList;
import com.ruoyi.common.core.domain.car.CarPageListReq;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 参数配置 信息操作处理
 *
 * @author ruoyi
 */
@RestController
@RequestMapping("/car/web")
public class CarController extends BaseController {

    @Resource
    private ICarService carService;

    /**
     * 获取全部车辆分类组详细信息
     * cateGroupCode : CCG_CATE(整体分类)；CCG_BRAND（品牌分类）；CCG_SERIES（系列分裂）；
     */
    @GetMapping("/cate/group/{cateGroupCode}/list")
    public AjaxResult list(@PathVariable("cateGroupCode") String cateGroupCode) {
        return success(carService.cateSelectList(cateGroupCode));
    }

    /**
     * 获取首页8辆车，同时返回车辆总数
     */
    @GetMapping("/home/car/list")
    public AjaxResult homeCarList(@RequestParam("cateId") Long cateId) {
        return success(carService.homeCarList(cateId));
    }

    /**
     * 车辆分页搜索列表
     */
    @PostMapping("/page/list")
    public TableDataInfo carPageList(CarPageListReq req) {
        startPage();
        List<CarList> carPageList = carService.carPageList(req);
        return getDataTable(carPageList);
    }

    /**
     * 车辆详情
     */
    @GetMapping("/car/detail/{carId}")
    public AjaxResult carDetailById(@PathVariable("carId") Long carId) {
        return success(carService.carDetailById(carId));
    }

    /**
     * 车辆问答
     */
    @GetMapping("/car/question/list")
    public AjaxResult carQuestionList() {
        return success(carService.carQuestionList());
    }

}
